﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Http;
using System.Web.Routing;


namespace ERPStore.Realtime
{
	public class RealtimeService : ERPStore.Services.IRealtimeMessageService
	{
		public RealtimeService(ERPStore.Logging.ILogger logger)
		{
			this.Logger = logger;
		}

		protected ERPStore.Logging.ILogger Logger { get; private set; }

		#region IRealtimeMessageService Members

		public void Send(string streamName, object data)
		{
			if (data == null
				|| streamName == null)
			{
				return;
			}

			var hubContext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<MessageHub>();
			hubContext.Clients.All[streamName].addMessage(data);
		}

		#endregion

	}
}
